﻿<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    CodeBehind="Default.aspx.cs" Inherits="mitasoft.ERS.Web._Default" %>

<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
    <script type="text/javascript">
        $(document).ready(function ()
        {

            $("#<%= btnFilter.ClientID %>").button();

            /////////////////////////////////////////////////
            //datepicker filter
            /////////////////////////////////////////////////
            var myDate = new Date();
            var month = myDate.getMonth() + 1;
            var prettyDate = month + '/' + myDate.getDate() + '/' + myDate.getFullYear();

            $("#dateFrom").datepicker();
            $("#dateFrom").val(prettyDate);
            $("#dateTo").datepicker();
            $("#dateTo").val(prettyDate);

            /////////////////////////////////////////////////
            //Row mouse over
            /////////////////////////////////////////////////
            $(".gridRow").hover(
            function ()
            {
                $(this).css('background-color', 'gray');
                $(this).css('color', 'white');

            },
            function ()
            {
                $(this).css('background-color', 'white');
                $(this).css('color', '#666666');
            }

            );

            /////////////////////////////////////////////////
            //Click on the row
            /////////////////////////////////////////////////
            var IssuePage = "../IssuePage.aspx";
            $(".gridRow").click(function ()
            {
                //$(this)[0].children[0].outerText
                $(this).fadeOut('fast', function ()
                {
                    $(this).fadeIn('fast', null);
                    window.location = IssuePage + "?id=" + $(this)[0].children[0].outerText;
                });
            });


            /////////////////////////////////////////////////
            //Highlight animate and redirect (main page options)
            /////////////////////////////////////////////////
            var options = {};

            $('#<%=mpoOpenIssue.ClientID%>').hover(
                 function () { $(this).effect('highlight', options, 400, null); },
                 function () { });

            $('#<%=mpoClosedIssue.ClientID%>').hover(
                 function () { $(this).effect('highlight', options, 400, null); },
                 function () { });

            $('#<%=mpoSubmitIssue.ClientID%>').hover(
                 function () { $(this).effect('highlight', options, 400, null); },
                 function () { });


            var nextLocation = '';

            $('#<%=mpoOpenIssue.ClientID%>').click(
            function ()
            {
                nextLocation = "../SubmitProblem.aspx";
                AnimateClick(this);

            });

            $('#<%=mpoClosedIssue.ClientID%>').click(
            function ()
            {
                nextLocation = "../SubmitProblem.aspx";
                AnimateClick(this);

            });

            $('#<%=mpoSubmitIssue.ClientID%>').click(
            function ()
            {
                nextLocation = "../SubmitProblem.aspx";
                AnimateClick(this);

            });

            function AnimateClick(control)
            {
                $(control).effect("bounce", null, 100, ChangeLocation);
            }

            function ChangeLocation()
            {
                window.location = nextLocation;
            }
            /////////////////////////////////////////////////
        });
    </script>
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
    <div style="padding-bottom: 20px">
        <h1>
            Home</h1>
    </div>
    <table>
        <tr>
            <td>
                Choose project
            </td>
        </tr>
        <tr>
            <td>
                <asp:DropDownList ID="ddlSelectedProject" AutoPostBack="true" DataTextField="Name"
                    DataValueField="id" runat="server" />
            </td>
        </tr>
        <tr>
            <td>
                <br />
            </td>
        </tr>
        <tr>
            <td>
                <div>
                    <ctrls:MainPageOption ID="mpoOpenIssue" runat="server" IssueType="OpenIssue" Title="Open Issues"
                        Description="View all open issues" />
                </div>
            </td>
            <td>
                <ctrls:MainPageOption ID="mpoClosedIssue" runat="server" IssueType="ClosedIssue"
                    Title="Closed Issues" Description="View all closed issues" />
            </td>
            <td>
                <ctrls:MainPageOption ID="mpoSubmitIssue" runat="server" IssueType="SubmitIssue"
                    Title="Submit Issue" Description="Submit new issue" />
            </td>
        </tr>
    </table>
    <div style="padding-bottom: 20px; padding-top: 20px">
        <h1>
            Latest activity</h1>
    </div>
    <div class="FormElementContur" style="width: 594px;">
        <table>
            <tr>
                <td>
                    Title:
                </td>
                <td>
                    <asp:TextBox Width="100" ID="tbFilterTitle" runat="server"></asp:TextBox>
                </td>
                <td>
                    &nbsp&nbsp&nbsp Date from:
                </td>
                <td>
                    <input id="dateFrom" type="text" />
                    &nbsp&nbsp to: &nbsp&nbsp
                    <input id="dateTo" type="text" />
                </td>
            </tr>
            <tr>
                <td colspan="4">
                    <asp:Button ID="btnFilter" CssClass="button" runat="server" Text="Filter" Width="90" />
                </td>
            </tr>
        </table>
    </div>
    <table>
        <tr>
            <td>
                <asp:GridView ID="gridLastestActivity" runat="server" AutoGenerateColumns="False"
                    DataSourceID="entityLatestActivity" RowStyle-CssClass="gridRow" Width="600px"
                    BorderColor="Transparent" BorderStyle="None" BorderWidth="0px" AllowPaging="True"
                    EmptyDataText="No data. Please refresh the page !" HeaderStyle-BorderColor="Transparent"
                    HeaderStyle-BorderStyle="None" RowStyle-BorderColor="Transparent" RowStyle-BorderStyle="None"
                    GridLines="None" DataKeyNames="IDIssue">
                    <Columns>
                        <asp:BoundField HeaderStyle-HorizontalAlign="Left" DataField="IDIssue" HeaderText="#ID"
                            ReadOnly="True" SortExpression="IDIssue" />
                        <asp:BoundField HeaderStyle-HorizontalAlign="Left" DataField="Title" HeaderText="Title"
                            ReadOnly="True" SortExpression="Title" />
                        <asp:BoundField HeaderStyle-HorizontalAlign="Left" DataField="ProjectName" HeaderText="Project"
                            ReadOnly="True" SortExpression="ProjectName" />
                        <asp:BoundField HeaderStyle-HorizontalAlign="Left" DataField="TypeDescription" HeaderText="Type"
                            ReadOnly="True" SortExpression="TypeDescription" />
                        <asp:BoundField HeaderStyle-HorizontalAlign="Left" DataField="StatusDescription"
                            HeaderText="Status" ReadOnly="True" SortExpression="StatusDescription" />
                    </Columns>
                    <HeaderStyle HorizontalAlign="Left" />
                    <PagerSettings Mode="NumericFirstLast" />
                    <PagerStyle BorderStyle="None" Font-Size="12px" Font-Bold="true" />
                    <RowStyle BorderColor="Transparent" BorderStyle="None" CssClass="gridRow" BorderWidth="0px">
                    </RowStyle>
                </asp:GridView>
                <asp:EntityDataSource ID="entityLatestActivity" runat="server" ConnectionString="name=ERSEntities"
                    DefaultContainerName="ERSEntities" EnableFlattening="False" EntitySetName="VW_IssueDetail"
                    EntityTypeFilter="VW_IssueDetail" OrderBy="it.IDIssue DESC">
                    <%--Where="it.IDProject = @projectID AND it.Title @titlu"--%>
                    <WhereParameters>
                        <%-- <asp:SessionParameter DefaultValue="1" DbType="Int32" SessionField="SESSION_CurrentProjectID" Name="projectID" />
                        <asp:SessionParameter DbType="String" SessionField="aaaa" DefaultValue="" Name="titlu" />--%>
                        <%--<asp:ControlParameter DbType="String" ControlID="tbFilterTitle" PropertyName="Text"
                            DefaultValue="" Name="titlu" />--%>
                    </WhereParameters>
                </asp:EntityDataSource>
            </td>
        </tr>
    </table>
</asp:Content>
